<template>
  <div class="song-list">
    <ul>
      <li
        class="item"
        v-for="(item, index) in songsList"
        :key="item.songid"
        @click="selectItem(item, index)"
      >
        <div class="content">
          <h2 class="song-name">{{ item.songname }}</h2>
          <p class="song-album">{{ getDesc(item) }}</p>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'songList',
  props: {
    songsList: {
      tyoe: Array,
      default: () => []
    }
  },
  methods: {
    getDesc (song) {
      return `${song.singer}·${song.albumname}`
    },
    selectItem (item, index) {
      this.$emit('select', item, index)
    }
  }
}

</script>
<style lang='stylus' scoped>
@import '~@/assets/stylus/variable'
@import '~@/assets/stylus/mixin'
.song-list
  .item
    display: flex
    align-items: center
    height: 64px
    box-sizing: border-box
    font-size: $font-size-medium
    .content
      flex: 1
      line-height: 20px
      overflow: hidden
      .song-name
        no-wrap()
        color: $color-text 
      .song-album
        no-wrap()
        margin-top: 4px
        color: $color-text-d
</style>
